home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 1180 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.4 KB  |  54 lines

  1. Path: ratty.wolfe.net!mcguire
  2. From: mcguire@wolfe.net (Mike McGuire)
  3. Newsgroups: comp.lang.c,comp.unix.programmer
  4. Subject: GCC 2.7.1 bug?
  5. Date: 11 Jan 1996 17:54:34 GMT
  6. Organization: Wolfe Internet Access, L.L.C.
  7. Message-ID: <4d3isq$ss@news1.wolfe.net>
  8. NNTP-Posting-Host: gonzo.wolfenet.com
  9. X-Newsreader: TIN [version 1.2 PL2]
  10.  
  11. Greetings,
  12.  
  13. First of all I would like to thank everyone for their suggestions to help me
  14. solve my SIGBUS problem.  Well, I have solved the problem, but what I did 
  15. seems unnecessary.  I think there may be a compiler bug.
  16.  
  17. The solution to get rid of my SIGBUS was to initialize a character 
  18. pointer in its declaration, but the first use of the pointer is assigning 
  19. a value to it, not dereferencing, or using its vaule.
  20.  
  21. The original code:
  22.  
  23.      char     *tmpfile;
  24.      ...
  25.      main() {
  26.      ...
  27.      tmpfile = mktemp( tmpname );     <===  SIGBUS!
  28.  
  29.  
  30. The solution:
  31.  
  32.      char     *tmpfile = 0;
  33.  
  34.  
  35. I compiled the code using gcc 2.7.1 for m68k-hp-hpux9.10, with the 
  36. -traditional option.  A diff of the assembled code gives me :
  37.  
  38. 42,45d41
  39. < .globl _tmpfile                     <=== The working version
  40. <       .even                         <=== Is .even an alignment directive?
  41. < _tmpfile:                           <===
  42. <       .long 0                       <===
  43. 2879a2876
  44. > .comm _tmpfile,4                    <=== Original, non-working version
  45.  
  46.  
  47. Any ideas why one works and one doesn't?  I am just really curious at this 
  48. point.
  49.  
  50.  
  51. Thanks a bunch,
  52.  
  53. Mike
  54.